﻿<Controls:MetroWindow x:Class="WpfClient.Views.SimpleViewWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:nota="clr-namespace:NotaManager;assembly=NotaManager"
        xmlns:local="clr-namespace:WpfClient"
        xmlns:viewModels="clr-namespace:WpfClient.Models"
        xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
        Title="NotaManager"  Width="600" Height="300"
        BorderBrush="{DynamicResource AccentColorBrush}"
        BorderThickness="1"
                      
        MouseRightButtonUp="MetroWindow_MouseRightButtonUp"
                      >
    <Controls:MetroWindow.Flyouts>
        <Controls:FlyoutsControl >
            <Controls:Flyout Name="SettingsPanel" Header="Options" Position="Left" Width="200" Theme="Accent">


            </Controls:Flyout>

        </Controls:FlyoutsControl>
    </Controls:MetroWindow.Flyouts>
    <Controls:MetroWindow.Resources>

        <local:RatingToColorConverter x:Key="RatingToColor"></local:RatingToColorConverter>
        <local:NullToVisibilityConverter x:Key="NullConverter"></local:NullToVisibilityConverter>
        <local:InvertBoolConverter x:Key="InvertConverter"></local:InvertBoolConverter>
        <local:BoolToVisibilityConverter x:Key="BoolConverter"></local:BoolToVisibilityConverter>

        <DataTemplate x:Key="LineTemplate" DataType="{x:Type viewModels:LineViewModel}">
            <Border BorderThickness="1" BorderBrush="Black" >
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto"></ColumnDefinition>
                        <ColumnDefinition></ColumnDefinition>
                    </Grid.ColumnDefinitions>

                    <Border Grid.Column="0"  BorderBrush="Black" BorderThickness="0 0 1 0">
                        <TextBlock 
                    MaxWidth="100" 
                    Margin="10 0 10 0"
                    Text="{Binding Number}"></TextBlock>
                    </Border>

                    <Border Grid.Column="1" Margin="0" Padding="0">
                        <StackPanel>
                            <TextBlock Text="{Binding Line.Eng}" FontWeight="Bold"></TextBlock>
                            <TextBlock Text="{Binding Line.Rus[0].Value}" FontSize="12"></TextBlock>
                        </StackPanel>
                    </Border>
                </Grid>
            </Border>

        </DataTemplate>




        <Style x:Key="InputTextBox" TargetType="{x:Type TextBox}">
            <Setter Property="Margin" Value="0 10"></Setter>
            <Setter Property="TextWrapping" Value="Wrap"></Setter>
            <Setter Property="Foreground" Value="Black"></Setter>
            <Setter Property="Padding" Value="5"></Setter>
            <Setter Property="FontSize" Value="15"></Setter>
            <!--<Setter Property="IsEnabled" Value="False"></Setter>-->
            <!--<Setter Property="IsReadOnly" Value="True"></Setter>-->
        </Style>

        <Style x:Key="Label" TargetType="{x:Type TextBlock}">
            <!--<Setter Property="Margin" Value="0 10"></Setter>-->
            <Setter Property="FontSize" Value="15"></Setter>
            <Setter Property="FontWeight" Value="ExtraBold"></Setter>
            <Setter Property="TextWrapping" Value="Wrap"></Setter>

        </Style>


        <DataTemplate x:Key="LineDetailsTemplate" DataType="{x:Type viewModels:LineViewModel}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"></RowDefinition>
                    <RowDefinition Height="auto"></RowDefinition>
                    <RowDefinition Height="auto"></RowDefinition>
                    <RowDefinition Height="0"></RowDefinition>
                </Grid.RowDefinitions>


                <Border Grid.Row="0" Margin="35 0 65 5" Padding="5 0 5 5" BorderBrush="{DynamicResource AccentColorBrush}" BorderThickness="1 0 1 1">
                    
                    <TextBlock Text="{Binding CurrentLine.Line.Eng}" Style="{StaticResource Label}" ></TextBlock>
                </Border>

                <Grid Grid.Row="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="30"></ColumnDefinition>
                        <ColumnDefinition Width="*"></ColumnDefinition>
                        <ColumnDefinition Width="auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>

                    <Border Grid.Column="1">
                        <TextBox Text="{Binding CurrentLine.ActiveTranslation.Value}" 
                                 Style="{StaticResource InputTextBox}"
                                 ></TextBox>
                    </Border>

                    <TextBlock
                    Grid.Column="0"             
                    Foreground="{Binding CurrentLine.ActiveTranslation.Rating, Converter={StaticResource RatingToColor}}"
                    VerticalAlignment="Center"
                    HorizontalAlignment="Center"
                    FontWeight="Bold"
                    Text="{Binding CurrentLine.ActiveTranslation.Rating}"
                    ></TextBlock>

                    <Viewbox Grid.Column="2" Width="50" Height="50" Margin="5">
                        <Button 
                        Style="{StaticResource MetroCircleButtonStyle}"
                        Content="{StaticResource appbar_layer}"
                        Command="{Binding ShowAllTranslations}"
                            
                        >
                        </Button>
                    </Viewbox>


                </Grid>


                <ItemsControl Grid.Row="1"
                        ItemsSource="{Binding CurrentLine.Line.Rus}"
                        Visibility="{Binding IsShowAllTranslations, Converter={StaticResource BoolConverter}}"
                              >
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="30"></ColumnDefinition>
                                    <ColumnDefinition Width="*"></ColumnDefinition>
                                    <ColumnDefinition Width="auto"></ColumnDefinition>
                                </Grid.ColumnDefinitions>

                                <Border Grid.Column="1">
                                    <TextBox Text="{Binding Value}" 
                                             Style="{StaticResource InputTextBox}" 
                                             FontSize="15"
                                             FontWeight="ExtraBold"
                                             Foreground="Gray"
                                             IsReadOnly="True"></TextBox>
                                </Border>

                                <TextBlock
                                    Grid.Column="0"             
                                    Foreground="{Binding Rating, Converter={StaticResource RatingToColor}}"
                                    VerticalAlignment="Center"
                                    HorizontalAlignment="Center"
                                    FontWeight="ExtraBold"
                                    Text="{Binding Rating}"
                                    ></TextBlock>

                                <Viewbox Grid.Column="2" Width="50" Height="50" Margin="5">
                                    <Button 
                                    Style="{DynamicResource MetroCircleButtonStyle}" 
                                    
                                    >
                                        <Canvas Width="76" Height="76" Clip="F1 M 0,0L 76,0L 76,76L 0,76L 0,0">
                                            <Path Width="40.25" Height="47" Canvas.Left="20" Canvas.Top="17" Stretch="Fill" Fill="{DynamicResource BlackBrush}" Data="F1 M 35,51L 51,51L 43,43L 49.25,43L 60.25,53.5L 50.25,64L 43,64L 51,56L 35,56L 35,51 Z M 20,17L 43.25,17L 56,29.75L 56,47.75L 52,43.75L 52,34L 39,34L 39,21L 24,21L 24,55L 33.75,55L 34.75,59L 20,59L 20,17 Z M 43,22.25L 43,30L 50.75,30L 43,22.25 Z "/>
                                        </Canvas>

                                    </Button>
                                </Viewbox>

                            </Grid>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>

                </ItemsControl>


            </Grid>


        </DataTemplate>

    </Controls:MetroWindow.Resources>


        
        <ScrollViewer VerticalScrollBarVisibility="Auto" >

            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"></RowDefinition>
                    <RowDefinition Height="auto">


                    </RowDefinition>
                </Grid.RowDefinitions>


                <ContentControl
                Grid.Row="0"
                Name="Line"
                ContentTemplate="{StaticResource LineDetailsTemplate}"
                Content="{Binding}"
                
                >
                </ContentControl>

                <StatusBar Grid.Row="1" >
                    <StatusBar.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal"></StackPanel>
                        </ItemsPanelTemplate>
                    </StatusBar.ItemsPanel>
                    <StatusBarItem>
                        <TextBlock Text="{Binding LastError}" TextWrapping="Wrap"></TextBlock>
                    </StatusBarItem>
                </StatusBar>
            </Grid>

        </ScrollViewer>
    
    
 

</Controls:MetroWindow>
